/*
 * UMLSynch plugin for Eclipse
 * http://umlsynch.googlecode.com
 *
 * Copyright 2008-2010, Evgeny Alexeyev
 * Licensed under the EPL - v1.0
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */

package com.googlecode.umlsynch.eclipse.IndexFilters;

import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
import org.eclipse.cdt.core.index.IndexFilter;

public class HasClassReferenceMemberIndexFilter extends IndexFilter {
	public String classReference = null;
	
	public boolean acceptBinding(IBinding binding) {
		if (classReference == null)
			return false;

		try {
			if (binding instanceof ICPPClassType) {
				ICPPClassType classType = (ICPPClassType)binding;
				ICPPField[] flds;

				flds = classType.getDeclaredFields();
				for (int t=0; t < flds.length; t++)
					if (flds[t].getType().toString().contains(classReference))
						return true;
			}
		} catch (DOMException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return false;
	}
}
